import request from "@/utils/request";
import { AxiosPromise } from "axios";
import { IPage, IUnionMember } from "./types";

/* 查询社团成员列表 */
export function getPageUnionMemberAPI(
  queryParams?: IPage
): AxiosPromise<PageResult<IUnionMember[]>> {
  return request({
    url: "/studentUnionUser/page",
    method: "get",
    params: queryParams,
  });
}
/* 根据id查询社团成员对象 */
export function getFormUnionMemberAPI(id: number): AxiosPromise<IUnionMember> {
  return request({
    url: `/studentUnionUser/${id}/form`,
    method: "get",
  });
}

/**
 * 添加社团成员
 *
 * @param data
 */
export function addUnionMemberAPI(data: any) {
  return request({
    url: "/studentUnionUser",
    method: "post",
    data: data,
  });
}

/**
 * 修改社团成员
 *
 * @param id
 * @param data
 */
export function updateUnionMemberAPI(id: number, data: IUnionMember) {
  return request({
    url: "/studentUnionUser/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除社团成员
 *
 * @param ids
 */
export function deleteUnionMemberAPI(ids: number) {
  return request({
    url: "/studentUnionUser/" + ids,
    method: "delete",
  });
}

/* 同意用户加入社团 */
export function updateStatusUnionMemberAPI(id: number) {
  return request({
    url: "/studentUnionUser/update/status/" + id,
    method: "put",
  });
}
